package club.gskj.gulimall.order.controller;

import java.util.Arrays;
import java.util.Map;

import club.gskj.gulimall.order.entity.OrderSettingEntity;
import club.gskj.gulimall.order.service.OrderSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import club.gskj.common.utils.PageUtils;
import club.gskj.common.utils.R;


/**
 * 订单配置信息
 *
 * @author 康纳-connor
 * @email 2417039231@gmail.com
 * @date 2021-03-27 16:26:19
 */
@RestController
@RequestMapping("ware/ordersetting")
public class OrderSettingController {
    @Autowired
    private club.gskj.gulimall.order.service.OrderSettingService OrderSettingService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("ware:ordersetting:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = OrderSettingService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("ware:ordersetting:info")
    public R info(@PathVariable("id") Long id) {
            OrderSettingEntity OrderSetting = OrderSettingService.getById(id);

        return R.ok().put("OrderSetting", OrderSetting);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("ware:ordersetting:save")
    public R save(@RequestBody OrderSettingEntity OrderSetting) {
            OrderSettingService.save(OrderSetting);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("ware:ordersetting:update")
    public R update(@RequestBody OrderSettingEntity OrderSetting) {
            OrderSettingService.updateById(OrderSetting);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("ware:ordersetting:delete")
    public R delete(@RequestBody Long[] ids) {
            OrderSettingService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
